<?php
// 简单工厂模式
class ProductA {}

class ProductB {}

class Factory
{
	public static function createProductA()
	{
		return new ProductA;
	}

	public static function createProductB()
	{
		return new ProductB;
	}
}
// 工厂方法模式
interface Product {}

class ProductA implements Product {}

class ProductB implements Product {}

interface Factory {static function createProduct();}

class FactoryA implements Factory
{
	public static function createProduct()
	{
		return new ProductA;
	}
}

class FactoryB implements Factory
{
	public static function createProduct()
	{
		return new ProductB;
	}
}
// 抽象方法模式
interface ProductA {}
interface ProductB {}
class ProductA1 implements ProductA {}
class ProductA2 implements ProductA {}
class ProductB1 implements ProductB {}
class ProductB2 implements ProductB {}
interface Factory
{
	static function createProductA();
	static function createProductB();
}
class Factory1 implements Factory
{
	public static function createProductA() {return new ProductA1;}
	public static function createProductB() {return new ProductB1;}
}
class Factory2 implements Factory
{
	public static function createProductA() {return new ProductA2;}
	public static function createProductB() {return new ProductB2;}
}